package com.hwhhhh.mygrad.fragment;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hwhhhh.mygrad.MessageActivity;
import com.hwhhhh.mygrad.R;
import com.hwhhhh.mygrad.adapter.MentionAdapter;
import com.hwhhhh.mygrad.dto.MentionDTO;

import java.util.ArrayList;
import java.util.List;

public class MessageFragment extends BaseFragment {
    private int type;
    private RecyclerView rvMessage;

    public MessageFragment(int type) {
        this.type = type;
    }

    @Override
    protected int initLayout() {
        return R.layout.fragment_message;
    }

    @Override
    protected void initView() {
        rvMessage = mRootView.findViewById(R.id.rv_message);
    }

    @Override
    protected void initData() {
        switch (type) {
            case MessageActivity.MENTION:
                MentionAdapter mentionAdapter = new MentionAdapter(getData());
                LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
                rvMessage.setAdapter(mentionAdapter);
                rvMessage.setLayoutManager(layoutManager);
                break;
            case MessageActivity.REPLY:
                break;
            case MessageActivity.LIKE:
                break;
            case MessageActivity.PRIVATE:
                break;
        }
    }

    private List<MentionDTO> getData() {
        List<MentionDTO> data = new ArrayList<>();
        MentionDTO mentionDTO = new MentionDTO();
        mentionDTO.setUname("用户二");
        mentionDTO.setContent("用户二发表的回复");
        mentionDTO.setParentContent("我自己发表的的回复");
        mentionDTO.setProfilePhoto("http://10.3.120.221:8081/api/images/users/1620220698556.jpg");
        data.add(mentionDTO);

        MentionDTO mentionDTO1 = new MentionDTO();
        mentionDTO1.setUname("用户3");
        mentionDTO1.setContent("用户3发表的回复");
        mentionDTO1.setParentContent("我自己发表的的回复2我自己发表的的回复2");
        mentionDTO1.setProfilePhoto("http://10.3.120.221:8081/api/images/users/1620220698556.jpg");
        data.add(mentionDTO1);

        MentionDTO mentionDTO2 = new MentionDTO();
        mentionDTO2.setUname("用户4");
        mentionDTO2.setContent("用户4发表的回复");
        mentionDTO2.setParentContent("我自己发表的的回复4我自己发表的的回复4");
        mentionDTO2.setProfilePhoto("http://10.3.120.221:8081/api/images/users/1620220698556.jpg");
        data.add(mentionDTO2);
        return data;
    }
}
